package com.fh.util.JGit;

import java.io.File;

import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git;

public class JGitUtil {
	public static String cloneRepository(String url,String localPath)
	{
		try{
			System.out.println("开始下载......");
			
			CloneCommand cc = Git.cloneRepository().setURI(url);
			cc.setDirectory(new File(localPath)).call();
			
			System.out.println("下载完成......");
			
			return "success";
		}catch(Exception e)
		{
			e.printStackTrace();
			return "error";
		}
	}
	
	
	public static void main(String[] args)
	{
		String localPath = "/Users/Recluse/Desktop/GitTest";
		String url = "https://github.com/RecluseGu/python3-webapp.git";
		
		cloneRepository(url,localPath);
	}
}
